File upload view and form layout

jamesperet 9 years ago
parent
commit
156f1217a8

+ 40 - 11
app/views/uploads/_form.html.erb

@@ -1,13 +1,42 @@
1
-<%= simple_form_for(@upload) do |f| %>
2
-  <%= f.error_notification %>
1
+<div class="media thumbnail" style="padding: 0px">
2
+<%= bootstrap_form_for(@upload, html: {style: 'margin-bottom: 0px;', class: 'form-bordered'}) do |f| %>
3
+  <%= f.alert_message "Please fix the errors below."%>
3 4
 
4
-  <div class="form-inputs">
5
-    <%= f.input :title %>
6
-    <%= f.file_field :file %>
7
-    <%= f.input :description %>
8
-  </div>
5
+	<div style="padding: 10px;">
6
+		<div class="controls controls-row">
7
+			<%= f.form_group :title, class: "span8", style: 'margin-left: 0px;' do %>
8
+			    <%= f.text_field :title, label: (t 'blog.title'), class: 'input-block-level', required: true %>
9
+			    <%= f.text_area :description, label: (t 'blog.description'), class: 'input-block-level', required: false, rows: 4 %>
10
+			<% end %>
11
+		
12
+			
13
+		
14
+		
15
+	
16
+		<div class="span2">
17
+			<div class="fileupload fileupload-new" data-provides="fileupload" style="margin-top: 5px;">
18
+				<div class="fileupload-preview thumbnail" data-trigger="fileinput" style="width: 320px; height: 145px;"><%=  image_tag @upload.file.to_s if @upload.file? %></div><br>
19
+				<span class="btn btn-default btn-file btn-mini" >
20
+					<span class="fileinput-new"></span>
21
+					<span class="fileinput-exists"></span>
22
+					<%= f.file_field :file, class: 'hidden', label: (t 'blog.select_image') %>
23
+				</span>
24
+			</div>
25
+		
26
+		</div>
27
+		</div>
28
+		
29
+		<%= f.form_group :description, class: "span8", style: 'margin-left: 0px; margin-top: -130px;' do %>
30
+		    
31
+		<% end %>
32
+			
9 33
 
10
-  <div class="form-actions">
11
-    <%= f.button :submit %>
12
-  </div>
13
-<% end %>
34
+	</div>
35
+	<div class="form-actions" style="margin: 0px;">
36
+		<%= f.submit (t 'blog.submit'), class: 'btn btn-success' %>
37
+		<%= link_to 'Show', @upload, class: 'btn' if action_name == 'edit' %>
38
+		<%= link_to (t 'blog.back'), admin_files_path, class: 'btn btn-link' %>
39
+	</div>
40
+
41
+	<% end %>
42
+</div>

+ 4 - 5
app/views/uploads/edit.html.erb

@@ -1,6 +1,5 @@
1
-<h1>Editing upload</h1>
1
+<div class="page-header">
2
+  <h1><%= t "uploads.edit_file" %></h1>
3
+</div>
2 4
 
3
-<%= render 'form' %>
4
-
5
-<%= link_to 'Show', @upload %> |
6
-<%= link_to 'Back', uploads_path %>
5
+<%= render 'form' %>

+ 4 - 5
app/views/uploads/new.html.erb

@@ -1,5 +1,4 @@
1
-<h1>New upload</h1>
2
-
3
-<%= render 'form' %>
4
-
5
-<%= link_to 'Back', uploads_path %>
1
+<div class="page-header">
2
+  <h1><%= t "uploads.upload_file" %></h1>
3
+</div>
4
+<%= render 'form' %>

+ 19 - 27
app/views/uploads/show.html.erb

@@ -1,30 +1,22 @@
1
-<p id="notice"><%= notice %></p>
1
+<div class="page-header">
2
+  <h1>
3
+	<%= @upload.title %>
4
+  	<%= link_to 'Edit', edit_upload_path(@upload), class: 'btn btn-mini pull-right', style: 'margin-top: 12px; margin-left: 6px;'%> 
5
+  	<%= link_to 'Destroy', @upload, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger btn-mini pull-right', style: 'margin-top: 12px;' %>
6
+  </h1>
7
+</div>
2 8
 
3
-<p>
4
-  <strong>Title:</strong>
5
-  <%= @upload.title %>
6
-</p>
9
+<div style="text-align:center">
10
+	<% if @upload.get_extension == 'jpg' || @upload.get_extension == 'png' %>
11
+	<%= image_tag @upload.file.to_s if @upload.file != nil %>
12
+	<% else %>
13
+	<%= link_to @upload.title, @upload.file.to_s %>
14
+	<% end %>
15
+</div>
7 16
 
8
-<p>
9
-  <strong>File:</strong><br>
10
-  <% if @upload.get_extension == 'jpg' || @upload.get_extension == 'png' %>
11
- 	<%= image_tag @upload.file.to_s if @upload.file != nil %>
12
-  <% else %>
13
-  	<%= link_to @upload.title, @upload.file.to_s %>
14
-  <% end %>
15
-</p>
17
+ <%= @upload.description %>
16 18
 
17
-<p>
18
-  <strong>File Type:</strong>
19
-  <%= @upload.file.file.content_type %>
20
-</p>
21
-
22
-<p>
23
-  <strong>Desciption:</strong>
24
-  <%= @upload.description %>
25
-</p>
26
-
27
-
28
-<%= link_to 'Edit', edit_upload_path(@upload) %> |
29
-<%= link_to 'Destroy', @upload, method: :delete, data: { confirm: 'Are you sure?' } %> |
30
-<%= link_to 'Back', admin_files_path %>
19
+<br>
20
+<div style="text-align:center">
21
+	<%= link_to 'Back', admin_files_path, class: 'btn btn-link' %> 
22
+</div>